#include "myrunnable.h"
#include <QDebug>
#include <QThread>
MyRunnable::MyRunnable(QProgressBar * progressBar)
{
    setAutoDelete(true);
    this->progressBar = progressBar;
}
MyRunnable::~MyRunnable(){
    qDebug() << QThread::currentThreadId() << "runnable析构" <<"\n";
}
void MyRunnable::run(){
    if(progressBar != nullptr){
        for(int i = 0; i < 100000; i++){
            progressBar->setValue(i); //设置值 (放在下一行的前面)
            emit(updateProcess(i)); //将进度发出去

        }
    }else{
        for(int i = 0; i < 100000; i++){
            emit(updateProcess(i)); //将进度发出去

        }
    }

    qDebug() << QThread::currentThreadId() << "runnable结束" << "\n";
}
